package com.zyz.controller;

import com.zyz.common.ResultInfo;
import com.zyz.domain.Coach;
import com.zyz.service.CoachService;
import com.zyz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CoachController {
    @Autowired
    private CoachService coachService;
    @Autowired
    private UserService userService;

    @GetMapping("/course/queryCoach")
    public ResultInfo  findCoach(){
        List<Coach> coachList =coachService.findCoach();

        return ResultInfo.success(coachList);
    }
    //选择教练到用户查询
    @PostMapping("/course/addCoachToUser")
    public ResultInfo addCoach(Integer id){
        userService.addCoach(id);
        return ResultInfo.success(null);
    }
    //验证教练是否被选择
    @PostMapping("/course/queryHasCoach")
    public ResultInfo isHave(){
        String msg=userService.isHave();
        return ResultInfo.success(msg);
    }
}
